package com.ydd.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.ydd.entity.SysRole;
import org.apache.ibatis.annotations.*;

import org.apache.ibatis.annotations.Delete;
import com.ydd.entity.SysRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface SysRoleMapper extends BaseMapper<SysRole> {

    /**
     * 角色分页
     * @param name
     * @return
     */
    Page<SysRole> pageQuery(String name);

    /**
     * 根据id查询角色
     * @param id
     * @return
     */

    SysRole list(String id);


    /**
     * 角色删除
     * @param id
     */
    @Delete("delete from sys_role where id = #{id}")
    void delById(String id);

    /**
     * 角色列表-全部
     * @return
     */
    List<SysRole> list();
    @Select("select * from sys_role where id = #{id}")
    SysRole getById(String id);



    /**
     * 角色修改
     * @param name
     * @param description
     */
    @Update("UPDATE sys_role SET name=#{name},description=#{description} WHERE id=#{id};")
    void update(String id,String name, String description);


    /**
     * 根据name查询id
     * @param name
     * @return
     */
    @Select("select id from sys_role where name = #{name}")
    String selectByName(String name);
    @Select("select `id`,`name` from sys_role")
    List<SysRole> selectAll();


}
